<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <div :style='{fontSize:fontSize + "px"}'>{{pmsg}}</div>
        <menu-item :pmsg='pmsg' @changefont='handle2($event)'></menu-item>
    </div>
    <script src="../js/vue.js"></script>
    <script>
        Vue.component('menu-item', {
            props: ['pmsg'],
            template: `
            <div>
            <div>{{pmsg}}</div>
            <button @click='$emit("changefont",5)'>改变父组件字体大小</button>
            </div>
            `
        })
        var vm = new Vue({
            el: '#app',
            data: {
                pmsg: '父组件中的内容',
                fontSize: 10
            },
            methods: {
                handle2: function (val) {
                    //改变字体大小
                    this.fontSize += val;
                }
            },
        })
    </script>
</body>

</html>